***Replication materials for Greene & Cross (2016), Section 6.2 & 6.3

*Set directory
cd "PATH TO REPLICATION MATERIAL FOLDER"

***Figure 3 in Section 6.2

*Fig 3(a)
clear
use "dates_Euro_fin.dta"

twoway (tsline euro, recast(bar) barwidth(15) ytitle("Number of speeches",size(large)) xtitle("Date",size(large))) (tsline finacial, recast(bar) barwidth(15) ytitle("Number of speeches",size(large)) xtitle("Date",size(large))), xlabel(17790 "A" 18174 "B" 18595 "C" 19200 "D", add angle(0) labgap(1)  tlength(5) custom labcolor(red)) scheme(s1color) ylab(0(100)300, grid) legend(ring(0) position(10) bmargin(large) rows(2))
graph display, ysize(2) xsize(4) scheme(s1mono)

*Fig 3(b)
clear
use "dates_treaties.dta"

twoway (tsline count, recast(bar) barwidth(15) scheme(s1color ) ytitle("Number of speeches",size(large)) xlabel(,angle(0)) xtitle("Date",size(large)) ylab(0(50)150, grid) xlabel(15133 "A" 15982 "B" 16192 "C" 17513 "D" 17695 "E" 18172 "F", add angle(0) labgap(1) custom labcolor(red) tlength(5))) 
graph display, ysize(2) xsize(4) scheme(s1mono)

*Fig 3(c)
clear
use "dates_fisheries.dta", replace

twoway (tsline count, recast(bar) barwidth(15) scheme(s1color ) ytitle("Number of speeches",size(large)) xtitle("Date",size(large)) ylab(0(50)200, grid) xlabel(,angle(45)) xlabel(18368 "A" 18821 "B", add angle(0) labgap(1) custom  tlength(5) labcolor(red)))
graph display, ysize(2) xsize(4) scheme(s1mono)


***Load regression dataset to replicate Section 6.3

clear
use "PA_Greene_Cross_Sec6_dataset.dta"

***Regressions on which Section 6.3 are based
glm MEPTopicWeight party_ideology mepdefecttoparty mepdefecttogroup i.EP_leader i.topic_chair i.topic_rap i.topic_com i.country_id i.group_id i.topic_id speech_count percent_present if MEPTopicWeight!=0, family(gauss) link(log) cluster(mep_id) 
nbreg MEPTopicCountMax party_ideology mepdefecttoparty mepdefecttogroup i.EP_leader i.topic_chair i.topic_rap i.topic_com i.country_id i.group_id i.topic_id speech_count percent_present, cluster(mep_id) 

***Create table (not included in paper but for reference)
eststo clear
quietly glm MEPTopicWeight party_ideology mepdefecttoparty mepdefecttogroup i.EP_leader i.topic_chair i.topic_rap i.topic_com i.country_id i.group_id i.topic_id speech_count percent_present if MEPTopicWeight!=0, family(gauss) link(log) cluster(mep_id) 
eststo m1, title("Summed weights")
quietly nbreg MEPTopicCountMax party_ideology mepdefecttoparty mepdefecttogroup i.EP_leader i.topic_chair i.topic_rap i.topic_com i.country_id i.group_id i.topic_id speech_count percent_present, cluster(mep_id) 
eststo m4, title("Single membership")
esttab, drop(*.country_id *.group_id *.topic_id) nobase label title(GLM_NB regressions) eform(0 1) b star  mtitles replace
esttab , drop(*.country_id *.topic_id) nobase label title(GLM_NB regressions) eform(0 1) b star  mtitles replace

***Figure 4 plotting regression results of interest
quietly glm MEPTopicWeight party_ideology mepdefecttoparty mepdefecttogroup i.EP_leader i.topic_chair i.topic_rap i.topic_com i.country_id i.group_id i.topic_id speech_count percent_present if MEPTopicWeight!=0, family(gauss) link(log) cluster(mep_id)
coefplot, scheme(s1color) drop(_cons *.country_id *.topic_id *.group_id) xline(0) xtitle("Coefficient") name(g1) title("Model 1: Topic weight")
graph display, scheme(s1mono)

quietly nbreg MEPTopicCountMax party_ideology mepdefecttoparty mepdefecttogroup i.EP_leader i.topic_chair i.topic_rap i.topic_com i.country_id i.group_id i.topic_id speech_count percent_present, cluster(mep_id) 
coefplot, scheme(s1color) drop(_cons *.country_id *.topic_id *.group_id) xline(1) eform xtitle("Odds ratios") name(g2) title("Model 2: Speech-count")
graph display, scheme(s1mono)


